export class mediaTools {
    /**
     * 日期不足两位补 0
     *
     * @param {string} value - 数据值
     * @return {string} - 日期不足两位补 0
     */
    private static fill(value: number): string {
        return value < 10 ? `0${value}` : `${value}`
    }

    static msToCountdownTime(ms: number): string {
        if (!ms) {
            return '00:00'
        }
        const days = Math.floor(ms / (1000 * 60 * 60 * 24))
        const hours = Math.floor((ms % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60))
        const minutes = Math.floor((ms % (1000 * 60 * 60)) / (1000 * 60))
        const seconds = Math.floor((ms % (1000 * 60)) / 1000)
        return `${days ? mediaTools.fill(days) + ':' : ''}${hours ? mediaTools.fill(hours) + ':' : ''}
        ${mediaTools.fill(minutes)}:${mediaTools.fill(seconds)} `.trim()
    }
}
